/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queryOpt;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.ArrayList;

public class showPlans {

    private ArrayList<subPlan> plans;

    public void showPlans() {
    }

    public void showPlans(ArrayList<subPlan> a) {
        this.plans = new ArrayList<subPlan>();
        for (int i = 0; i < a.size(); i++) {
            this.plans.add(a.get(i));

        }
    }

    public void show(ArrayList<ArrayList<Double>> selectSet) throws Exception {

        FileOutput.set("result.txt");
        for (int i = 0; i < this.plans.size(); i++) {
            System.out.println("=================================");
            FileOutput.write("=================================");
            FileOutput.newline();
            this.plans.get(i).showSelectivity(selectSet.get(i));
            System.out.println("---------------------------------");
            FileOutput.write("---------------------------------");
            FileOutput.newline();
            if (this.plans.get(i).getisrightest() == 1 && this.plans.get(i).getBranchSign() == 1) {
            } else {
                System.out.print("if");
                FileOutput.write("if");
            }
            this.plans.get(i).show();
            System.out.print("\n");
            FileOutput.newline();
            System.out.println("---------------------------------");
            FileOutput.write("---------------------------------");
            FileOutput.newline();
            System.out.println("Cost: " + this.plans.get(i).getBestCost());
            FileOutput.write("Cost: " + this.plans.get(i).getBestCost());
            FileOutput.newline();
        }
        FileOutput.close();
    }
}
